#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, m;
string s[1000006], ans[1000006];
vector<pair<int, int>> fps;
const int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const int d2[8][2] = {{-1, -1}, {1, 1}, {-1, 1}, {1, -1}, {0, 1}, {0, -1}, {1, 0}, {-1, 0}};
map<pair<int, int>, int> vis;

bool getsum2(int x, int y) {
	int sm = 0;
	for (int k = 0; k < 4; ++k) {
		int nx = x + d[k][0], ny = y + d[k][1];
		if (nx >= 1 && nx <= n && ny >= 1 && ny <= m) {
			sm += (ans[nx][ny] == '1');
		}
	}
	return !!sm;
}
int getsum(int x, int y) {
	bool sm = 1;
	for (int k = 0; k < 4; ++k) {
		int nx = x + d[k][0], ny = y + d[k][1];
		if (nx >= 1 && nx <= n && ny >= 1 && ny <= m) {
			sm &= !getsum2(nx, ny);
		}
	}
	return sm;
}

signed main() {
//	freopen("indian.in", "r", stdin); freopen("indian.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
//		cin >> s[i];
		for (int j = 1; j <= m; ++j) s[i].push_back('#');
		s[i] = " " + s[i];
		ans[i] = s[i];
		for (int j = 1; j <= m; ++j) {
			if (s[i][j] == '#') ans[i][j] = '0';
			else if (s[i][j] == '.') ans[i][j] = '.';
		}
	}
	for (int j = 1; j <= m + !(m & 1); j += 2) {
		for (int i = (j % 4 == 1 ? 1 : 2); i <= n + !(n & 1); i += 2) {
			if (i > n || j > m || s[i][j] == '.') {
			//	cout << "falied " << i << " " << j <<"\n";
				fps.push_back({i, j});
			} else {
				ans[i][j] = '1';
			//	cout << "suc " << i << " " << j << "\n";
			}
		}
	}
	for (auto i : fps) {
		int ok = 0;
//		cout << "find " << i.first << " " << i.second << "\n";
		for (int k = 0; k < 8; ++k) {
			int nx = d2[k][0] + i.first, ny = d2[k][1] + i.second;
//			cout << "fchk " << nx << " " << ny << "\n";
			if (nx >= 1 && nx <= n && ny >= 1 && ny <= m && ans[nx][ny] != '1' && ans[nx][ny] != '.') {
			//	cout << "chk " <<nx << " " << ny << "\n";
				if (getsum(nx, ny)) {
//					cout << "af suc " <<nx << " " << ny << "\n";
					ans[nx][ny] = '1';
				///	ok = 1;
					break;
				}
			}
		}
	}
	int tot1 = 0;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			tot1 += (ans[i][j] == '1');
			cout << ans[i][j];
		}
		cout << "\n";
	}
//	assert(tot1 <= (n * m + n * 2 + m * 2) / 5);
	cout << (n * m + n * 2 + m * 2) /5 << "\n";
	cout << tot1 <<"\n";

	return 0;
}
